package com.ruoyi.report_ljlm.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.ruoyi.report_ljlm.domain.vo.WcbgBsInfoVo;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report_ljlm.domain.vo.YsdgsfbgBsInfoVo;
import com.ruoyi.report_ljlm.domain.bo.YsdgsfbgBsInfoBo;
import com.ruoyi.report_ljlm.service.IYsdgsfbgBsInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 压实度试验检测报告(灌砂法)
 *
 * @author llb
 * @date 2024-08-27
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report_ljlm/ysdgsfbgBsInfo")
public class YsdgsfbgBsInfoController extends BaseController {

    private final IYsdgsfbgBsInfoService iYsdgsfbgBsInfoService;

    /**
     * 查询压实度试验检测报告(灌砂法)列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<YsdgsfbgBsInfoVo> list(YsdgsfbgBsInfoBo bo, PageQuery pageQuery) {
        return iYsdgsfbgBsInfoService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出压实度试验检测报告(灌砂法)列表
     */
    @SaCheckLogin
    @Log(title = "压实度试验检测报告(灌砂法)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(YsdgsfbgBsInfoBo bo, HttpServletResponse response) {
        List<YsdgsfbgBsInfoVo> list = iYsdgsfbgBsInfoService.queryList(bo);
        ExcelUtil.exportExcel(list, "压实度试验检测报告(灌砂法)", YsdgsfbgBsInfoVo.class, response);
    }

    /**
     * 获取压实度试验检测报告(灌砂法)详细信息
     *
     * @param excelId 主键
     */
    @SaCheckLogin
    @GetMapping("/{excelId}")
    public R<YsdgsfbgBsInfoVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long excelId) {
        return R.ok(iYsdgsfbgBsInfoService.queryById(excelId));
    }

    /**
     * 新增压实度试验检测报告(灌砂法)
     */
    @SaCheckLogin
    @Log(title = "压实度试验检测报告(灌砂法)", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody YsdgsfbgBsInfoBo bo) {
        return toAjax(iYsdgsfbgBsInfoService.insertByBo(bo));
    }

    /**
     * 修改压实度试验检测报告(灌砂法)
     */
    @SaCheckLogin
    @Log(title = "压实度试验检测报告(灌砂法)", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody YsdgsfbgBsInfoBo bo) {
        return toAjax(iYsdgsfbgBsInfoService.updateByBo(bo));
    }

    /**
     * 删除压实度试验检测报告(灌砂法)
     *
     * @param excelIds 主键串
     */
    @SaCheckLogin
    @Log(title = "压实度试验检测报告(灌砂法)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{excelIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] excelIds) {
        return toAjax(iYsdgsfbgBsInfoService.deleteWithValidByIds(Arrays.asList(excelIds), true));
    }

    /**
     * 检测结论
     */
    @SaCheckLogin
    @Log(title = "生成  报告 检测结论", businessType = BusinessType.OTHER)
    @PutMapping("/jcjl")
    public R<YsdgsfbgBsInfoVo> jcjl(@RequestBody YsdgsfbgBsInfoVo vo) {
        return R.ok(iYsdgsfbgBsInfoService.jcjl(vo));
    }
}
